// $(function () {
//     var isKz = $("#isKz").val();
//     if (isKz == "1") {
//         $("#jzRecord").hide();
//     }
//     $("#revisitTime").val(setDateTime(new Date(), 0));
//     var seleteRevisitValue = $('#revisitValue').val();
//     if (seleteRevisitValue != "") {
//         $("#revisit option[value='" + seleteRevisitValue + "']").attr("selected", "selected");
//     }
//     $.post(Feng.ctxPath + "/tcRevisit/getSfList", function (data) {
//         var li = "";
//         for (var i = 0; i < data.length; i++) {
//             li += '<li id="' + data[i].id + '" style="position: relative"><a href="javascript:;">' + data[i].title + '</a><span class="glyphicon glyphicon-remove" style="position: absolute;top: 50%;right: 10px;transform: translateY(-50%)"></span></li>'
//         }
//         $("#dropdownMenu2Ul").html(li)
//     }, "json");
//     $.post(Feng.ctxPath + "/tcRevisit/getJgList", function (data) {
//         var li = "";
//         for (var i = 0; i < data.length; i++) {
//             li += '<li id="' + data[i].id + '" style="position: relative"><a href="javascript:;">' + data[i].title + '</a><span class="glyphicon glyphicon-remove" style="position: absolute;top: 50%;right: 10px;transform: translateY(-50%)"></span></li>'
//         }
//         $("#dropdownMenu1Ul").html(li)
//     }, "json");
// });

function addsf() {
    var index = layer.open({
        type: 2,
        title: '&nbsp',
        area: ['40%', '40%'],
        fix: true,
        maxmin: true,
        content: Feng.ctxPath + '/tcRevisit/to_addsf/'
    });
    this.layerIndex = index;
}

function addjg() {
    var index = layer.open({
        type: 2,
        title: '&nbsp',
        area: ['40%', '40%'],
        fix: true,
        maxmin: true,
        content: Feng.ctxPath + '/tcRevisit/to_addjg/'
    });
    this.layerIndex = index;
}

function submitTc1() {//保存待计划
    var params = {
        followStatus: $("#followStatus").val(),
        consumptionStatus: $("#consumptionStatus").val(),
        revisit: $("#revisit").val(),
        remarks: $("#remarks2").val(),
        revisitContent: $("#revisitContent").val(),
        reservationsId: $("#reservationsId").val(),
        customerId: $("#customerId").val(),
        revisitTime: $("#revisitTime").val(),
        arrivalStore: $("#arrivalStore").val()
    };
    if ($("#followStatus").val() == null || $("#followStatus").val() == "") {
        alert("请选择跟踪状态!");
        return false;
    }
    if ($("#consumptionStatus").val() == null || $("#consumptionStatus").val() == "") {
        alert("请选择消费状态!");
        return false;
    }
    if ($("#revisit").val() == null || $("#revisit").val() == "") {
        alert("请选择回访人员!");
        return false;
    }
    if (($("#remarks2").val() == null || $("#remarks2").val() == "")) {
        alert("请填写回访计划!");
        return false;
    }
    $.ajax({
        url: Feng.ctxPath + "/tcRevisit/addTcContent2",
        type: "post",
        data: params,
        success: function (data) {
            Feng.success('操作成功!');
            window.location.href = Feng.ctxPath + '/consultantDetails/consultantToDetailByTab/' + $("#customerId").val() + '/3/0'
        }
    });
}

function submitTc2() {//回访完成
    var params = {
        followStatus: $("#followStatus").val(),
        consumptionStatus: $("#consumptionStatus").val(),
        revisit: $("#revisit").val(),
        remarks: $("#remarks2").val(),
        revisitContent: $("#revisitContent").val(),
        reservationsId: $("#reservationsId").val(),
        customerId: $("#customerId").val(),
        revisitTime: $("#revisitTime").val(),
        arrivalStore: $("#arrivalStore").val()
    };
    if ($("#followStatus").val() == null || $("#followStatus").val() == "") {
        alert("请选择跟踪状态!");
        return false;
    }
    if ($("#consumptionStatus").val() == null || $("#consumptionStatus").val() == "") {
        alert("请选择消费状态!");
        return false;
    }
    if ($("#revisit").val() == null || $("#revisit").val() == "") {
        alert("请选择回访人员!");
        return false;
    }
    if (($("#revisitContent").val() == null || $("#revisitContent").val() == "")) {
        alert("请填写回访结果!");
        return false;
    }
    $.ajax({
        url: Feng.ctxPath + "/tcRevisit/addTcContentOver",
        type: "post",
        data: params,
        success: function (data) {
            Feng.success('操作成功!');
            window.location.href = Feng.ctxPath + '/consultantDetails/consultantToDetailByTab/' + $("#customerId").val() + '/3/0'
        }
    });
}

$("#dropdownMenu1Ul").on('click', '.glyphicon-remove', function (e) {
    e.stopPropagation();
    var value = $(this).parent().attr('id');
    if (confirm("是否删除此模板？")) {
        $.ajax({
            url: Feng.ctxPath + "/tcRevisit/deleteJgById",
            type: "post",
            data: {
                id: value
            },
            success: function (data) {
                Feng.success("删除成功!");
                window.location.reload();
            },
            error: function (data) {
            }
        });
    }
});

$("#dropdownMenu2Ul").on('click', '.glyphicon-remove', function (e) {
    e.stopPropagation();
    var value = $(this).parent().attr('id');
    if (confirm("是否删除此模板？")) {
        $.ajax({
            url: Feng.ctxPath + "/tcRevisit/deleteSfById",
            type: "post",
            data: {
                id: value
            },
            success: function (data) {
                Feng.success("删除成功!");
                window.location.reload();
            },
            error: function (data) {
            }
        });
    }
});

$("#dropdownMenu1Ul").on('click', 'li', function () {
    var value = $(this).attr('id');
    $.ajax({
        url: Feng.ctxPath + "/tcRevisit/getJgById",
        type: "post",
        data: {
            id: value
        },
        success: function (data) {
            $("#revisitContent").val(data.remarks)
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
});

$("#dropdownMenu2Ul").on('click', 'li', function () {
    var value = $(this).attr('id')
    $.ajax({
        url: Feng.ctxPath + "/tcRevisit/getSfById",
        type: "post",
        data: {
            id: value
        },
        success: function (data) {
            $("#remarks2").val(data.remarks)
            $("#remarks").val(data.remarks)
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
});

checkDates = function checkDates() {
    var newTime = $("#revisitTime").val();
    var beforeTime = setDateTime(new Date(), 0);
    var start = new Date(newTime.replace("-", "/").replace("-", "/"));
    var end = new Date(beforeTime.replace("-", "/").replace("-", "/"));
    if (start < end) {
        alert('时间不可小于今天！');
        $("#revisitTime").val(setDateTime(new Date(), 0));
    }
};